<!--
 * @Author: your name
 * @Date: 2021-06-27 18:04:34
 * @LastEditTime: 2021-06-29 20:58:57
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue_shop_mananger\src\views\home\home.vue
-->
<template>
  <el-container class="_container">
    <el-header>
      <!-- 头部子组件 -->
      <t-header/>
    </el-header>
    <el-container>
      <el-aside :width="isCollaspe?'64px':'250px'">
        <nav-bar :menus="menuList" @toggleMenu="toggleMenu"/>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
</el-container>
</template>
<script>
import tHeader from './componets/title_header.vue'
import navBar from './componets/navBar.vue'
export default {
  data(){
    return {
      menuList:[],
      isCollaspe:false,
    }
  },
  components:{
    tHeader,
    navBar,

  },
  methods: {
    exit(){
      window.sessionStorage.clear();
      this.$router.push('/login');
    },
    async getMenuData(){
      const {data:res}=await this.$http.get('menus');
      if(res.meta.status!==200)return this.$message.error("菜单请求失败")
      this.menuList=res.data;
      console.log(this.menuList);
    },
    toggleMenu(isCollaspe){
      this.isCollaspe=isCollaspe
    }
  },
  created(){
    this.getMenuData();
  }
}
</script>
<style lang="scss" scoped>
._container{
  height: 100%;
  
}
.el-header{
  color: #f6f6f6;
  background-color:#373D41;
}
.el-aside{
  background-color: #333744;
  
}
.el-main{
  background-color: #EAEDF1;
}
</style>